package com.example.imageexample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.example.imageexample.Main2.DividerLine;
import com.example.imageexample.Main2.GridAdapter;

import java.util.ArrayList;
import java.util.List;

public class Main2Activity extends AppCompatActivity {

    private List<String> info ;
    private RecyclerView gridView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

        gridView = (RecyclerView) findViewById(R.id.recyclerView);

        GridLayoutManager gridLayoutManager=new GridLayoutManager(this,3);
//        StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
        gridView.setLayoutManager(gridLayoutManager);
        gridView.setNestedScrollingEnabled(true);
        gridView.setItemAnimator(new DefaultItemAnimator());

        info=new ArrayList<>();
        for(int i=0;i<8;i++) {
            info.add("res://mipmap/" + R.mipmap.penguins);
        }

        GridAdapter adapter = new GridAdapter(this);
        adapter.addAllData(info);
        gridView.setAdapter(adapter);

        DividerLine dividerLine = new DividerLine(this,-1);
        dividerLine.setSize(10);
        dividerLine.setColor(0xFFFFFF);
        gridView.addItemDecoration(dividerLine);
    }
}
